import random
import cards

from abstract_player import AbstractPlayer
from math import sqrt

class ArtificialPlayer3(AbstractPlayer):
    def __init__(self, game, name, bluffing = 0):
        AbstractPlayer.__init__(self)
        
        self.game = game
        self.name = name
        self.bluffing = bluffing
    
    def do_move(self):
        opponent_probability = self.opponent_probability_context()
        my_probability = self.get_simple_probability()
        
        #print("Hole cards: " + cards.card_names(self.hole_cards))
        #print("Probability of winning: " + str(my_probability))
        #print("Opponent probability: " + str(opponent_probability))
        #print("Pot odds: " + str(self.pot_odds()))
        
        if self.game.checkable(self.current_bet):
            if random.random() < self.bluffing:
                self.bet(self.game.pot)
            elif my_probability > 0.5:
                self.bet(max(self.game.pot, self.game.min_raise()))
            else:
                self.check()
        else:
            ratio = (my_probability / opponent_probability) / self.pot_odds()
            print("ratio: " + str(ratio))
            if ratio > 1.5:
                self.raise_amount(max(self.game.pot, self.game.min_raise()))
            elif ratio > 1:
                self.call()
            else:
                self.fold()
        
    def __str__(self):
        return self.name + " (a3)"